<?php
/**
 * Created by PhpStorm.
 * User: xuke
 * Date: 16/7/14
 * Time: 下午3:01
 */

namespace App\Logic;

use App\Http\Model\Admin AS AdminModel;
use App\Exceptions\ApiException;

class AdminLogic extends BaseLogic
{
    protected $_admin;
    
    public function __construct($admin)
    {
        $this->_admin = $admin;
    }

    public static function initByAdmin($admin)
    {
        if (is_numeric($admin))
        {
            $admin = AdminModel::find($admin);
            if (!$admin)
            {
                throw new ApiException("管理员信息不存在", -2);
            }
        }else if(!$admin instanceof AdminModel)
        {
            throw new ApiException("管理员参数错误", -2);
        }
        return new static ($admin);
    }
    
    
}